'\" te
.\"  Copyright (c) 2001, Sun Microsystems, Inc.  All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH GETTEXT 1 "Sep 17, 2001"
.SH NAME
gettext \- retrieve text string from message database
.SH SYNOPSIS
.LP
.nf
\fBgettext\fR [\fB-d\fR \fItextdomain\fR | \fB-\(midomain\fR=\fItextdomain\fR]
     [\fItextdomain\fR] \fImsgid\fR
.fi

.LP
.nf
\fBgettext\fR \fB-s\fR [\fB-e\fR] [\fB-n\fR]
     [\fB-d\fR \fItextdomain\fR | \fB-\(midomain\fR=\fItextdomain\fR] \fImsgid\fR...
.fi

.SH DESCRIPTION
.sp
.LP
The \fBgettext\fR utility retrieves a translated text string corresponding to
string \fImsgid\fR from a message object generated with \fBmsgfmt\fR(1). The
message object name is derived from the optional argument \fItextdomain\fR if
present, otherwise from the \fBTEXTDOMAIN\fR environment. If no domain is
specified, or if a corresponding string cannot be found, \fBgettext\fR prints
\fImsgid\fR.
.sp
.LP
Ordinarily, \fBgettext\fR looks for its message object in
\fB/usr/lib/locale/\fIlang\fR/LC_MESSAGES\fR where \fIlang\fR is the locale
name. If present, the \fBTEXTDOMAINDIR\fR environment variable replaces the
pathname component up to \fIlang\fR.
.sp
.LP
This command interprets C escape sequences such as \fB\et\fR for tab. Use
\fB\e\e\fR to print a backslash. To produce a message on a line of its own,
either enter \fB\en\fR at the end of \fImsgid\fR, or use this command in
conjunction with \fBprintf\fR(1).
.sp
.LP
When used with the \fB-s\fR option, \fBgettext\fR behaves like \fBecho\fR(1).
But it does not simply copy its arguments to standard output. Instead, those
messages found in the selected catalog are translated.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-d\fR \fItextdomain\fR\fR
.ad
.br
.na
\fB\fB-\(midomain\fR=\fItextdomain\fR\fR
.ad
.RS 26n
Retrieves translated messages from the domain \fItextdomain\fR, if
\fItextdomain\fR is not specified as an operand.
.RE

.sp
.ne 2
.na
\fB\fB-e\fR\fR
.ad
.RS 26n
Enables expansion of some escape sequences if used with the \fB-s\fR option.
.RE

.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 26n
Suppresses trailing newline if used with the \fB-s\fR option.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 26n
Behaves like \fBecho\fR(1) (see DESCRIPTION above). If the \fB-s\fR option is
specified, no expansion of C escape sequences is performed and a newline
character is appended to the output, by default.
.RE

.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fItextdomain\fR\fR
.ad
.RS 14n
A domain name used to retrieve the messages. This overrides the specification
by the \fB-d\fR or \fB-\(midomain\fR options, if present.
.RE

.sp
.ne 2
.na
\fB\fImsgid\fR\fR
.ad
.RS 14n
A key to retrieve the localized message.
.RE

.SH ENVIRONMENT VARIABLES
.sp
.ne 2
.na
\fB\fBLANG\fR\fR
.ad
.RS 17n
Specifies locale name.
.RE

.sp
.ne 2
.na
\fB\fBLC_MESSAGES\fR\fR
.ad
.RS 17n
Specifies messaging locale, and if present overrides \fBLANG\fR for messages.
.RE

.sp
.ne 2
.na
\fB\fBTEXTDOMAIN\fR\fR
.ad
.RS 17n
Specifies the text domain name, which is identical to the message object
filename without \fB\&.mo\fR suffix.
.RE

.sp
.ne 2
.na
\fB\fBTEXTDOMAINDIR\fR\fR
.ad
.RS 17n
Specifies the pathname to the message database. If present, replaces
\fB/usr/lib/locale\fR.
.RE

.SH SEE ALSO
.sp
.LP
.BR echo (1),
.BR msgfmt (1),
.BR printf (1),
.BR gettext (3C),
.BR setlocale (3C),
.BR attributes (7)
.SH NOTES
.sp
.LP
This is the shell equivalent of the library routine \fBgettext\fR(3C).
